package com.arpa.wms.domain.enums;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.enums.IEnum;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: rfwang
 * @Date 2021/6/29
 * @Description:
 */
public enum JobTypeEnum implements IEnum<String> {
    /**
     * 费用类型
     */
    PACK("pack","打包"),
    PASTE("paste","贴单"),
    PACK_PASTE("pack_paste","打包和贴单");

    /**
     * 值
     */
    private String value;

    /**
     * 描述
     */
    private String desc;

    public static JobTypeEnum catchMessage(String msg) {
        JobTypeEnum result = null;
        for (JobTypeEnum s : values()) {
            if (s.getDesc().equals(msg)) {
                result = s;
                break;
            }
        }
        return result;
    }


    JobTypeEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static String translate(String value){
        JobTypeEnum item = ENUM_MAP.get(value);
        if(item != null){
            return item.getDesc();
        }
        return StrUtil.EMPTY;
    }

    private static final Map<String, JobTypeEnum> ENUM_MAP = new HashMap();

    static {
        for(JobTypeEnum item: values()){
            ENUM_MAP.put(item.getValue(), item);
        }

    }

    public static JobTypeEnum getEnumByValue(String value) {
        return ENUM_MAP.get(value);
    }

    @Override
    public String getValue() {
        return value;
    }

    @Override
    public String toString(){
        return this.desc;
    }

    public String getDesc() {
        return desc;
    }

}
